﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

/* Generated with http://xmltocs.com/ */
namespace EDMXParserV1
{
    public class EntityContainer
    {
        public EntityContainer()
        {
            EntitySets = new List<EntitySet>();
            AssociationSets = new List<AssociationSet>();
            FunctionImports = new List<FunctionImport>();
        }
        public String Name { get; set; }
        public String AnnotationLazyLoadingEnabled { get; set; }
        public string p1LazyLoadingEnabled { get; set; }
        public List<EntitySet> EntitySets { get; set; }
        public List<AssociationSet> AssociationSets { get; set; }
        public List<FunctionImport> FunctionImports { get; set; }

        public static EntityContainer New(System.Xml.XmlNode Node)
        {
            EntityContainer EntityContainer = new EntityContainer();
            foreach (XmlAttribute Attribute in Node.Attributes)
            {
                switch (Attribute.Name)
                {
                    case "Name":
                        EntityContainer.Name = Attribute.Value;
                        break;

                    case "annotation:LazyLoadingEnabled":
                        EntityContainer.AnnotationLazyLoadingEnabled = Attribute.Value;
                        break;
                    case "p1:LazyLoadingEnabled":
                        EntityContainer.p1LazyLoadingEnabled = Attribute.Value;
                        break;

                    default:
                        Globals.AttributeSwitchCoder(Attribute);
                        break;
                }
            }

            foreach (XmlNode ChildNode in Node.ChildNodes)
            {
                switch (ChildNode.Name)
                {
                    case "EntitySet":
                        EntitySet EntitySet = EntitySet.New(ChildNode);
                        EntityContainer.EntitySets.Add(EntitySet);
                        break;
                    case "AssociationSet":
                        AssociationSet AssociationSet = AssociationSet.New(ChildNode);
                        EntityContainer.AssociationSets.Add(AssociationSet);
                        break;
                    case "FunctionImport":
                        FunctionImport FunctionImport = FunctionImport.New(ChildNode);
                        EntityContainer.FunctionImports.Add(FunctionImport);
                        break;

                    default:
                        Globals.NodeSwitchCoder(ChildNode);
                        break;
                }
            }
            return EntityContainer;
        }
    }
}
